package com.wei.czz.common.enums.store;

import com.wei.czz.common.dto.common.NameValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * Created by IntelliJ IDEA.
 *
 * @author wyw
 * date: 2023-12-27 10:01:07
 * className: StoreSubmitTypeEnum
 * version: 1.0
 * description:
 */
@Getter
@AllArgsConstructor
public enum StoreSubmitTypeEnum {

    SUBMIT_STORE(0, "商店提交"),
    STORE_MODIFY(1, "商店修改"),
    ADD_STORE_ACCOUNT(20, "添加商店账户"),
    STORE_ACCOUNT_MODIFY(21, "商店账户修改"),
    ADD_STORE_BOSS(30, "添加商店老板"),
    STORE_BOSS_MODIFY(31, "商店老板修改"),
    ;

    /**
     * 值
     */
    private final Integer value;

    /**
     * 名称
     */
    private final String name;

    /**
     * 获取商店提交类型枚举名称
     * @param value 值
     * @return 名称
     */
    public static String getName(Integer value) {
        for (StoreSubmitTypeEnum storeSubmitTypeEnum : values()) {
            if (storeSubmitTypeEnum.value.equals(value)) {
                return storeSubmitTypeEnum.name;
            }
        }
        return "";
    }

    /**
     * 获取商店提交类型枚举列表
     * @return 商店提交类型枚举列表
     */
    public static List<NameValue<Integer>> getList() {
        return Stream.of(values())
                .map(storeSubmitTypeEnum -> new NameValue<>(storeSubmitTypeEnum.name, storeSubmitTypeEnum.value))
                .collect(Collectors.toList());
    }

    /**
     * 获取商店提交类型枚举映射
     * @return 映射
     */
    public static Map<Integer, String> getMap() {
        Map<Integer, String> map = new HashMap<>();
        for (StoreSubmitTypeEnum storeSubmitTypeEnum : values()) {
            map.put(storeSubmitTypeEnum.value, storeSubmitTypeEnum.name);
        }
        return map;
    }
}
